package com.cq.hd.product.controller;

import com.cq.hd.common.entity.mq.ActiveBrowseMsg;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.product.api.TbActiveBrowseApi;
import com.cq.hd.product.api.dto.ActiveBrowseDto;
import com.cq.hd.product.api.dto.ActiveBrowsePageDto;
import com.cq.hd.product.api.vo.ActiveBrowsePageVo;
import com.cq.hd.product.api.vo.ActiveBrowseVo;
import com.cq.hd.product.service.TbActiveBrowseService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 活动浏览记录表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-12-01
 */
@RestController
public class TbActiveBrowseController implements TbActiveBrowseApi {

    @Autowired
    private TbActiveBrowseService activeBrowseService;

    @ApiOperation(value = "浏览活动列表")
    @ApiImplicitParam(name = "activeBrowsePageDto", value = "实体", paramType = "query", dataType = "ActiveBrowsePageDto")
    @ApiResponse(response = ActiveBrowsePageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<ActiveBrowsePageVo>> page(ActiveBrowsePageDto activeBrowsePageDto) {
        return ResultGenerator.success(activeBrowseService.pageActiveBrowse(activeBrowsePageDto));
    }

    @ApiOperation(value = "清空浏览记录")
    @Override
    public Result<Boolean> clear(Long userId) {
        return ResultGenerator.success(activeBrowseService.clear(userId));
    }

    @ApiOperation(value = "清空近2个月浏览记录")
    @Override
    public Result<Boolean> removeActiveBrowseJob() {
        return ResultGenerator.success(activeBrowseService.removeActiveBrowseJob());
    }

    @ApiOperation(value = "根据条件获取浏览列表")
    @Override
    public Result<List<ActiveBrowseVo>> listByDto(ActiveBrowseDto activeBrowseDto) {
        return ResultGenerator.success(activeBrowseService.listByDto(activeBrowseDto));
    }

    @ApiOperation(value = "消费活动浏览消息")
    @Override
    public Result<Boolean> consumerActiveBrowseMsg(@RequestBody ActiveBrowseMsg activeBrowseMsg) {
        return ResultGenerator.success(activeBrowseService.consumerActiveBrowseMsg(activeBrowseMsg));
    }
}
